#include <iostream>
#include <string>
#include <cctype>
using namespace std;

string reverseOnlyLetters(string s) 
{
	int pforward = 0;
	int preverse = s.size() - 1;
	while (pforward < preverse)
	{
		while ((!isalpha(s[pforward])) && (pforward < preverse))
		{
			++pforward;
		}
		while ((!isalpha(s[preverse])) && (pforward < preverse))
		{
			--preverse;
		}
		
		swap(s[pforward], s[preverse]);
	}
	
	return s;
}

int main()
{
	string s("ab-cd");
	reverseOnlyLetters(s);
	cout << s << endl;
	
	return 0;
}
